home *** CD-ROM | disk | FTP | other *** search
/ Computer Inter@ctive 17 / Computer Interactive cdrom 17 - gen 99.iso / ZDNETIT / CONTENT / SMTPCEMS.ZIP / STATUS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-15  |  2.2 KB  |  75 lines

  1. /*
  2. **  STATUS.C [edit EMAIL.H before compiling]
  3. **
  4. **  This program displays the header from each
  5. **  email message on the SMTP server.
  6. */
  7.  
  8. #include <windows.h>
  9. #include <stdio.h>
  10. #include "see.h"
  11. #include "email.h"
  12.  
  13. #define BUFF_SIZE   2048
  14. #define TEMP_SIZE    128
  15.  
  16. static char Buffer[BUFF_SIZE];
  17. static char Temp[TEMP_SIZE];
  18.  
  19. void ErrorExit(int Code)
  20. {seeErrorText(Code,(LPSTR)Buffer,512);
  21.  printf("SEE Error %d: %s\n", Code, Buffer);
  22.  seeClose();
  23.  exit(1);
  24. }
  25.  
  26. void main(void)
  27. {int i, n;
  28.  int Code;
  29.  int NbrMsg;
  30.  int Version; 
  31.  long MsgSize;
  32.  
  33.  Version = seeStatistics(SEE_GET_VERSION);
  34.  printf("SEE4C Version %1x.%1x.%1x\n",0x0f&(Version>>8),0x0f&(Version>>4),0x0f&Version);
  35.  
  36.  /* define diagnostics log file */
  37.  seeStringParam(SEE_LOG_FILE, (LPSTR)"status.log"); 
  38.  /* connect to POP3 server */
  39.  printf("Connecting to %s ...",(LPSTR)POP3_HOST_NAME);
  40.  Code = seePop3Connect(
  41.     (LPSTR)POP3_HOST_NAME,             /* POP3 server */
  42.     (LPSTR)POP3_USER_NAME,             /* user */ 
  43.     (LPSTR)POP3_PASSWORD);             /* Password */
  44.  if(Code>=0) printf("OK\n");
  45.  else ErrorExit(Code);  
  46.  /* get # messages waiting  */
  47.  puts("Getting message count...");
  48.  NbrMsg = seeGetEmailCount();                   
  49.  if(NbrMsg<0) ErrorExit(NbrMsg); 
  50.  printf("%d messages waiting.\n", NbrMsg);
  51.  /* read message headers */
  52.  for(i=1;i<=NbrMsg;i++)
  53.    {/* read message i */
  54.     printf("---[ Message %d, ",i);
  55.     Code = seeGetEmailLines(i, 0, (LPSTR)Buffer, BUFF_SIZE); 
  56.     if(Code<0) ErrorExit(Code);
  57.     MsgSize = seeGetEmailSize(i);
  58.     printf("%d bytes ]-------------------------------\n",MsgSize);
  59.     ///Buffer[Code] = '\0';
  60.     /* display "DATE: " line */
  61.     n = seeExtractText((LPSTR)Buffer, "Date: ", (LPSTR)Temp, TEMP_SIZE);
  62.     if(n>0) printf("%s", (LPSTR)Temp);  
  63.     /* display "FROM: " line */
  64.     n = seeExtractText((LPSTR)Buffer, "From: ", (LPSTR)Temp, TEMP_SIZE);
  65.     if(n>0) printf("%s", (LPSTR)Temp);  
  66.     /* display "SUBJECT: " line */
  67.     n = seeExtractText((LPSTR)Buffer, "Subject: ", (LPSTR)Temp, TEMP_SIZE);
  68.     if(n>0) printf("%s", (LPSTR)Temp);
  69.    }
  70.  printf("----------------------------------------------------\n");
  71.  seeClose();
  72. } /* end main */
  73.  
  74.  
  75.